package pro.lingwu.rainbowmall.handler

import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.RestControllerAdvice
import pro.lingwu.rainbowmall.exception.NotFindException
import pro.lingwu.rainbowmall.exception.VerifyFailedException

@RestControllerAdvice
class CommonExceptionHandler {

    @ExceptionHandler(value = [VerifyFailedException::class])
    fun handleVerifyFailed(exception: VerifyFailedException): ResponseEntity<*>
    = ResponseEntity.status(HttpStatus.NOT_ACCEPTABLE).body(exception.message)


    @ExceptionHandler(value = [NotFindException::class])
    fun handleNotFindUser(exception: NotFindException): ResponseEntity<*>
    = ResponseEntity.status(HttpStatus.NOT_FOUND).body(exception.message)
}